﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using RescueApp.Models;

namespace RescueApp.Data
{
    public class RescueApplyConfig : IEntityTypeConfiguration<RescueApply>
    {
        public void Configure(EntityTypeBuilder<RescueApply> rescueApply)
        {
            rescueApply.ToTable("RescueApply");
            rescueApply.HasKey(a => a.RescueID);
            rescueApply.Property(a => a.RescueID).ValueGeneratedOnAdd(); // 主键由数据库自动生成
            rescueApply.Property(a => a.VehicleLicensePlate).IsRequired().HasMaxLength(10);
            rescueApply.Property(a => a.CarType).IsRequired().HasMaxLength(20);
            rescueApply.Property(a => a.DriverIdentification).IsRequired().HasMaxLength(18);
            rescueApply.Property(a => a.ApplicantPhone).IsRequired().HasMaxLength(20);
            rescueApply.Property(a => a.RescueLocation).IsRequired().HasMaxLength(50);
            rescueApply.Property(a => a.RepairDestination).IsRequired().HasMaxLength(50);
            rescueApply.Property(a => a.ApplicationDate).IsRequired();
        }
    }
}